include $(TOPDIR)/rules.mk

PKG_NAME:=libcairo_lede
PKG_VERSION:=1.18.4
PKG_RELEASE:=1

PKG_SRC_NAME:=cairo
PKG_SOURCE:=$(PKG_SRC_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=https://cairographics.org/releases/
PKG_HASH:=skip

PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
PKG_LICENSE:=LGPL-2.1-or-later MPL-1.1
PKG_LICENSE_FILES:=COPYING COPYING-LGPL-2.1 COPYING-MPL-1.1

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SRC_NAME)-$(PKG_VERSION)

PKG_FIXUP:=autoreconf
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1

include $(INCLUDE_DIR)/package.mk

define Package/libcairo_lede
    SECTION:=libs
    SUBMENU:=Libraries
    CATEGORY:=Printing
    TITLE:=libcairo_lede
    URL:=https://cairo.freedesktop.org/
    DEPENDS:=+libpng +libfreetype +fontconfig +pixman +glib2 +libjpeg +zlib +liblzo
endef

define Package/libcairo_lede/description
  Cairo is a 2D graphics library with support for multiple output devices.
endef

CONFIGURE_ARGS += \
	--oldincludedir="$(STAGING_DIR)/usr/include" \
	--x-includes="$(STAGING_DIR)/usr/include" \
	--x-libraries="$(STAGING_DIR)/usr/lib" \
	--without-x \
	--enable-pdf \
	--enable-png \
	--enable-ps \
	--enable-svg \
	--enable-tee \
	--enable-ft \
	--disable-glesv2 \
	--disable-glesv3 \
	--enable-test-surfaces=no \
	--enable-xcb=no \
	--enable-xlib-xrender=no \
	--enable-xcb=no \
	--enable-xlib-xcb=no \
	--enable-xcb-shm=no

define Package/libcairo_lede/install
	$(INSTALL_DIR) $(1)/usr/lib
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib
	$(INSTALL_DIR) $(1)/usr/lib/cairo
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/cairo/*.so $(1)/usr/lib/cairo
endef

define Build/InstallDev
	$(INSTALL_DIR) $(1)/usr/include/cairo
	$(CP) $(PKG_INSTALL_DIR)/usr/include/cairo/*.h $(1)/usr/include/cairo
	$(INSTALL_DIR) $(1)/usr/lib
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib
	$(INSTALL_DIR) $(1)/usr/lib/cairo
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/cairo/*.so $(1)/usr/lib/cairo
	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/*.pc $(1)/usr/lib/pkgconfig
endef

$(eval $(call BuildPackage,libcairo_lede))
